<?php

class eventForms extends form {

	public static function add($errors)
	{
		$content.= '<form method="post" enctype="multipart/form-data">
				<fieldset>
					<legend>Add Event</legend>
					<ul>
						<li>Title: <input type="text" name="title" /></li>
						<li>Location: <input type="text" name="location" /></li>
						<li>Description:</li>
						<li>' . form::textarea('description', self::postValue('description')) . '</li>
						<li>' . form::date($_POST['date']) . '</li>
						<li>time:
						<select name="hours">
							<option>Hour</option>';
						for($i = 1; $i <= 12; $i++)
						{
							$content .= '
							<option value="' . $i . '">' . $i .'</option>';
						}
		$content .=	'
						</select>
						<select name="minutes">
							<option>Minute</option>';
						for($i = 0; $i <= 60; $i++)
						{
							if($i<10)
							{
								$content .= '
								<option value="0' . $i . '">0' . $i .'</option>';
							}
							else
							{
								$content .= '
								<option value="' . $i . '">' . $i .'</option>';
							}
						}
		$content .=	'
						</select>
						<select name="ampm">
							<option value="am">AM</option>
							<option value="pm">PM</option>
						</select>
						</li>
						<li><input type="submit" name="submit" value="Add Event" /></li>
					</ul>
				</fieldset>
				</form>';
				
		return $content;
	}
	
	public static function edit($errors, $event)
	{
		$content .= '<form method="post" enctype="multipart/form-data">
				<fieldset>
					<legend>Edit Event</legend>
					<ul>
						<li>Title: <input type="text" name="title" value="' . $event->title . '" /></li>
						<li>Location: <input type="text" name="location" value="' . $event->location . '" /></li>
						<li>Description:</li>
						<li>' . form::textarea('description', $event->description) . '</li>
						<li>' . form::date(date('m/d/Y',$event->date)) . '</li>
						<li>time:
						<select name="hours">
							<option>Hour</option>';
						for($i = 1; $i <= 12; $i++)
						{
							$content .= '
								<option value="' . $i;
								
								if($i == date('g',$event->date))
								{
									$content .= ' selected="selected" ';
								}
								
								$content .='">' . $i .'</option>';
						}
		$content .=	'
						</select>
						<select name="minutes">
							<option>Minute</option>';
						for($i = 0; $i <= 60; $i++)
						{
							if($i<10)
							{
								$content .= '
								<option value="0' . $i;
								
								if('0'.$i == date('i',$event->date))
								{
									$content .= ' selected="selected" ';
								}
								
								$content .='">0' . $i .'</option>';
							}
							else
							{
								$content .= '
								<option value="' . $i;
								
								if($i == date('i',$event->date))
								{
									$content .= ' selected="selected" ';
								}
								
								$content .='">' . $i .'</option>';
							}
						}
		$content .=	'
						</select>
						<select name="ampm">
							<option value="am">AM</option>
							<option value="pm"';
							
							if(date('G',$event->date) >12)
							{
								$content .= ' selected="selected" ';
							}
							
		$content .=			'>PM</option>
						</select>
						</li>
						<li><input type="submit" name="submit" value="Edit Event" /></li>
					</ul>
				</fieldset>
				</form>';
				
		return $content;
	}
	
}
?>